import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";

type Result = {
  code: boolean;
  data?: Array<any>;
  msg: string;
};

type ResultTable = {
  success: boolean;
  data?: {
    /** 列表数据 */
    list: Array<any>;
    /** 总条目数 */
    total?: number;
    /** 每页显示条目个数 */
    pageSize?: number;
    /** 当前页数 */
    currentPage?: number;
  };
};

/** 获取附件列表 */
export const attachmentList = (data?: object) => {
  return http.request<ResultTable>(
    "post",
    baseUrlApi("/admin/system/General/Attachment/list"),
    {
      data
    }
  );
};

/** 删除附件 */
export const deleteAttachment = (params?: object) => {
  return http.request<Result>(
    "delete",
    baseUrlApi("/admin/system/General/Attachment/delete"),
    {
      params
    }
  );
};

/**批量删除 */
export const batchDeleteAttachment = (data?: object) => {
  return http.request<Result>(
    "delete",
    baseUrlApi("/admin/system/General/Attachment/batchDelete"),
    {
      data
    }
  );
};

/** 获取附件类型 */
export const attachmentTypes = (data?: object) => {
  return http.request<Result>(
    "get",
    baseUrlApi("/admin/system/General/AttachmentType/list"),
    {
      data
    }
  );
};

/** 获取分类 */
export const attachmentCategory = (data?: object) => {
  return http.request<Result>(
    "get",
    baseUrlApi("/admin/system/General/Attachment/category"),
    {
      data
    }
  );
};

/** 修改附件类型 */
export const updateAttachmentType = (params?: object) => {
  return http.request<Result>(
    "post",
    baseUrlApi("/admin/system/General/Attachment/updateCategory"),
    {
      params
    }
  );
};
